#include <iostream>
using namespace std;
#include <vector>

class Solution
{
public:
    int maxProfit(vector<int>& prices)
    {
        int ret = 0, n = prices.size();
        for (int i = 0; i < n; i++)
        {
            int j = i;
            while (j + 1 < n && prices[j + 1] > prices[j])
                ++j;

            ret += prices[j] - prices[i];
            i = j;
        }

        return ret;
    }
};


int main()
{
    vector<int> nums = { 1,2,3,4,5 };
    cout << Solution().maxProfit(nums);
    return 0;
}